package com.example.sport.Class;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.example.sport.R;

import java.util.List;

public class ClassAdapter extends RecyclerView.Adapter<ClassAdapter.ViewHolder> {
    private List<ClassList> mClassList;


    static class ViewHolder extends RecyclerView.ViewHolder{
        ImageView classImage;
        TextView className;
        public ViewHolder( View view) {
            super(view);
            classImage=(ImageView) view.findViewById(R.id.class_image);
            className=(TextView) view.findViewById(R.id.class_name);
        }
    }
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.class_item,parent,false);
        ViewHolder holder=new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder( ViewHolder holder, int position) {
        ClassList classList=mClassList.get(position);
        holder.className.setText(classList.getClassName());
        holder.classImage.setImageResource(classList.getClassImageId());
    }

public ClassAdapter(List<ClassList> classList){
        mClassList=classList;
}


    @Override
    public int getItemCount() {
        return mClassList.size();
    }
}
